home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / ncurses-5.3 / ncurses / base / lib_printw.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-27  |  4.3 KB  |  143 lines

  1. /****************************************************************************
  2.  * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
  3.  *                                                                          *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a  *
  5.  * copy of this software and associated documentation files (the            *
  6.  * "Software"), to deal in the Software without restriction, including      *
  7.  * without limitation the rights to use, copy, modify, merge, publish,      *
  8.  * distribute, distribute with modifications, sublicense, and/or sell       *
  9.  * copies of the Software, and to permit persons to whom the Software is    *
  10.  * furnished to do so, subject to the following conditions:                 *
  11.  *                                                                          *
  12.  * The above copyright notice and this permission notice shall be included  *
  13.  * in all copies or substantial portions of the Software.                   *
  14.  *                                                                          *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
  16.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
  17.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
  18.  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
  19.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
  20.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
  21.  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  22.  *                                                                          *
  23.  * Except as contained in this notice, the name(s) of the above copyright   *
  24.  * holders shall not be used in advertising or otherwise to promote the     *
  25.  * sale, use or other dealings in this Software without prior written       *
  26.  * authorization.                                                           *
  27.  ****************************************************************************/
  28.  
  29. /****************************************************************************
  30.  *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
  31.  ****************************************************************************/
  32.  
  33. /*
  34. **    lib_printw.c
  35. **
  36. **    The routines printw(), wprintw() and friends.
  37. **
  38. */
  39.  
  40. #include <curses.priv.h>
  41.  
  42. MODULE_ID("$Id: lib_printw.c,v 1.13 2002/10/05 22:52:21 tom Exp $")
  43.  
  44. NCURSES_EXPORT(int)
  45. printw(NCURSES_CONST char *fmt,...)
  46. {
  47.     va_list argp;
  48.     int code;
  49.  
  50. #ifdef TRACE
  51.     va_start(argp, fmt);
  52.     T((T_CALLED("printw(%s%s)"),
  53.        _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
  54.     va_end(argp);
  55. #endif
  56.  
  57.     va_start(argp, fmt);
  58.     code = vwprintw(stdscr, fmt, argp);
  59.     va_end(argp);
  60.  
  61.     returnCode(code);
  62. }
  63.  
  64. NCURSES_EXPORT(int)
  65. wprintw(WINDOW *win, NCURSES_CONST char *fmt,...)
  66. {
  67.     va_list argp;
  68.     int code;
  69.  
  70. #ifdef TRACE
  71.     va_start(argp, fmt);
  72.     T((T_CALLED("wprintw(%p,%s%s)"),
  73.        win, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
  74.     va_end(argp);
  75. #endif
  76.  
  77.     va_start(argp, fmt);
  78.     code = vwprintw(win, fmt, argp);
  79.     va_end(argp);
  80.  
  81.     returnCode(code);
  82. }
  83.  
  84. NCURSES_EXPORT(int)
  85. mvprintw(int y, int x, NCURSES_CONST char *fmt,...)
  86. {
  87.     va_list argp;
  88.     int code;
  89.  
  90. #ifdef TRACE
  91.     va_start(argp, fmt);
  92.     T((T_CALLED("mvprintw(%d,%d,%s%s)"),
  93.        y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
  94.     va_end(argp);
  95. #endif
  96.  
  97.     if ((code = move(y, x)) != ERR) {
  98.     va_start(argp, fmt);
  99.     code = vwprintw(stdscr, fmt, argp);
  100.     va_end(argp);
  101.     }
  102.     returnCode(code);
  103. }
  104.  
  105. NCURSES_EXPORT(int)
  106. mvwprintw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt,...)
  107. {
  108.     va_list argp;
  109.     int code;
  110.  
  111. #ifdef TRACE
  112.     va_start(argp, fmt);
  113.     T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"),
  114.        y, x, win, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
  115.     va_end(argp);
  116. #endif
  117.  
  118.     if ((code = wmove(win, y, x)) != ERR) {
  119.     va_start(argp, fmt);
  120.     code = vwprintw(win, fmt, argp);
  121.     va_end(argp);
  122.     }
  123.     returnCode(code);
  124. }
  125.  
  126. NCURSES_EXPORT(int)
  127. vwprintw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
  128. {
  129.     char *buf;
  130.     int code = ERR;
  131.  
  132.     T((T_CALLED("vwprintw(%p,%s,%p)"),
  133.        win, _nc_visbuf(fmt), argp));
  134.  
  135.     if ((buf = _nc_printf_string(fmt, argp)) != 0) {
  136.     code = waddstr(win, buf);
  137. #if USE_SAFE_SPRINTF
  138.     free(buf);
  139. #endif
  140.     }
  141.     returnCode(code);
  142. }
  143.